SRCDIR = src
SRCFILES = $(shell find src -name '*.java')

JPPFILES = $(shell ./jpp files)

BINDIR = bin

RESFILES = res/*

GSONLIB = ../lib/gson.jar

CLASSPATH = $(GSONLIB)

MAINCLASS = jrobutt.GameFrame

JAR = JRobutt.jar

VERSIONFILE = vstring

WEBFILES = index.cgi common.py main.html.fmt settings.json $(VERSIONFILE)

PYCACHE = __pycache__


default: compile jar sign

# stands for "test"
t: default clean

compile:
	mkdir -p $(BINDIR)
	./jpp
	javac -d $(BINDIR) -classpath $(CLASSPATH) $(JPPFILES) $(SRCFILES)

jar:
	(cd $(BINDIR) && jar xf ../$(GSONLIB) com)
	jar cef $(MAINCLASS) $(JAR) $(VERSIONFILE) -C $(BINDIR) . $(RESFILES)

STOREPASS_FILE = ~/vault/passwords/coachman-keystore
KEYPASS_FILE = ~/vault/passwords/coachman-keystore-jrobutt
sign:
	cat $(STOREPASS_FILE) $(KEYPASS_FILE) | jarsigner $(JAR) jrobutt

deploy:
	cp $(JAR) ~/share/deploy
	cp $(WEBFILES) $(JAR) /var/www/jrobutt

clean:
	rm -f $(JPPFILES)
	rm -rf $(BINDIR) $(JAR) $(PYCACHE)
